1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2       <tr align=center>
3         <td
class="title" width="100%">Tin t&#7913;c: <a href="./?act=news_m&page=<? echo $_REQUEST['page']?>&cat=<? echo $_REQUEST['cat']; ?>"><font class="V10pt" color="#ffffff">Nh&#7853;p M&#7899;i</font></a>&nbsp;&nbsp;
4     </td>
5       </tr>
6     </table>
7 <?
8 $MAXPAGE=
20;
9
10     
switch ($_GET['action'])
11     {
12         
case 'del' :
13             $id = $_GET[
'id'];
14             $news=GetNewsInfo($id);
15             
if ($news)
16             {
17                 $sql =
"delete from news where id='".$id."'";
18                 $result = mysql_query($sql,$con);
19                 
if ($result)
20                 {
21                     
if (file_exists("../".$news['news_image'])) unlink("../".$news['news_images']);
22                     echo
"<p align=center class='err'>&#272;ã xóa thành công</p>";
23                 }
24                     
else echo "<p align=center class='err'>Không th&#7875; xóa d&#7919; li&#7879;u</p>";
25             }
26             
break;
27     }
28 ?>
29
30 <?
31     
if (isset($_POST['ButDel'])) {
32         $cnt=
0;
33         
foreach ($_POST['chk'] as $id)
34         {
35             $news=GetNewsInfo($id);
36             
if ($news)
37             {
38                 @$result = mysql_query(
"delete from news where id='".$id."'",$con);
39                 
if ($result) {
40                     $cnt++;
41                     
if (file_exists("../".$news['image'])) unlink("../".$news['news_images']);
42                 }
43             }
44         }
45         echo
"<p align=center class='err'>&#272;ã xóa ".$cnt."</p>";
46     }
47 ?>
48 <?
49     
if (isset($_POST['newstop'])) {
50         $cnt=
0;
51         
foreach ($_POST['chk'] as $id)
52         {
53             
54             $sql_news=mysql_query(
"SELECT * FROM news where id='".$id."' ");
55             $news=mysql_fetch_assoc($sql_news);
56
57             
if ($news)
58             {
59                 @$result = mysql_query(
"update news set top=1 where id='".$id."' ",$con);
60                 
if ($result) {
61                     $cnt++;
62
63                 }
64             }
65         }
66         echo
"<p align=center class='err'>Đã thêm ".$cnt." vào tin top</p>";
67     }
68 ?>
69 <?
70     
if (isset($_POST['un_newstop'])) {
71         $cnt=
0;
72         
foreach ($_POST['chk'] as $id)
73         {
74             
75             $sql_news=mysql_query(
"SELECT * FROM news where id='".$id."' ");
76             $news=mysql_fetch_assoc($sql_news);
77
78             
if ($news)
79             {
80                 @$result = mysql_query(
"update news set top=0 where id='".$id."' ",$con);
81                 
if ($result) {
82                     $cnt++;
83
84                 }
85             }
86         }
87         echo
"<p align=center class='err'>Đã hủy ".$cnt." tin top</p>";
88     }
89 ?>
90
91 <?
92     $page = $_GET[
"page"];
93     $p=
0;
94     
if ($page!='') $p=$page;
95     $
where="1=1";
96     
if ($_REQUEST['cat']!='') $where="cat_id=".$_REQUEST['cat'];
97 ?>
98 <form method=
"POST" name="frmList" action="index.php">
99 <input type=
"hidden" name="act" value="news">
100 <input type=hidden name=
"page" value="<? echo $_REQUEST['page']; ?>">
101 <?
102 function taotrang($sql,$link,$nitem,$itemcurrent)
103 {
global $con;
104     $ret=
"";
105     $result = mysql_query($sql, $con) or die(
'Error' . mysql_error());
106     $
value = mysql_fetch_array($result);
107     $plus = (($
value['cnt'] % $nitem)>0);
108     
for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
109     {
110         
if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
111         
else $ret .= ($i+1)." ";
112     }
113     
return $ret;
114 }
115     $pageindex=taotrang(
"select count(*) from news where $where","./?act=".$_REQUEST['act']."&cat=".$_REQUEST['cat']."&sortby=".$_REQUEST['sortby']."&direction=".$_REQUEST['direction']."&page=",$MAXPAGE,$page);
116 ?>
117
118 <table cellspacing=
"0" cellpadding="0" width="100%">
119 <?
if ($_REQUEST['code']==1) echo '<tr><td colspan=2 align="center" class="err">&#272;ã c&#7853;p nh&#7853;t thành công</td></tr>'; ?>
120 <tr>
121 <td
class="smallfont">Trang : <? echo $pageindex; ?></td>
122 <td height=
"30" align="right" class="smallfont">
123     <
select size="1" name="ddCat" class="smallfont">
124 <?
125     $ms=GetListCatnews_admin(
0);
126     echo
'<option value="">[T&#7845;t c&#7843;]</option>';
127     
foreach ($ms as $m)
128         
if ($m[0]!=$_REQUEST['cat'])
129             echo
'<option value="'.$m[0].'">'.$m[1].'</option>';
130         
else
131             echo
'<option selected value="'.$m[0].'">'.$m[1].'</option>';
132 ?>
133     </
select>
134     <input type=
"button" value="Chuy&#7875;n" class="button" onclick="window.location='./?act=news&cat='+ddCat.value">
135     </td>
136 </tr>
137 </table>
138
139 <?
140 function GetLinkSort($order)
141 {
142     $direction=
"";
143     
if ($_REQUEST['direction']==''||$_REQUEST['direction']!='0')
144         $direction=
"0";
145     
else
146         $direction=
"1";
147     
148     
return "./?act=".$_REQUEST['act']."&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."&sortby=".$order."&direction=".$direction;
149 }
150 ?>
151
152 <table border=
"1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
153   <tr>
154     <td align=center nowrap
class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
155     <td colspan=
"2" nowrap class="title">&nbsp;</td>
156     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(1); ?>"><b>Mã</b></a></td>
157     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(2); ?>"><b>Tiêu &#273;&#7873;</b></a></td>
158     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(2); ?>"><b>S&#7889; th&#7913; t&#7921;</b></a></td>
159     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(3); ?>"><b>Top</b></a></td>
160     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(3); ?>"><b>Hình</b></a></td>
161     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(7); ?>"><b>Ngày</b></a></td>
162     <td align=
"center" nowrap class="title"><a class="title" href="<? echo GetLinkSort(9); ?>"><b>Danh m&#7909;c</b></a></td>
163   </tr>
164   
165   <?
166             $sortby=
"order by thutu";
167             
if ($_REQUEST['sortby']!='') $sortby="order by ".(int)$_REQUEST['sortby'];
168             $direction=($_REQUEST[
'direction']==''||$_REQUEST['direction']=='0'?"desc":"");
169             $sql=
"select * from news where $where and user='' $sortby $direction limit ".($p*$MAXPAGE).",".$MAXPAGE;
170             $result=mysql_query($sql,$con);
171             $i=
0;
172             
while(($row=mysql_fetch_array($result)))
173             {
174             $i++;
175             
if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
176             $sql_cat=mysql_query(
"SELECT * FROM news_cat where id='".$row['cat_id']."' ");
177             $row_cat=mysql_fetch_array($sql_cat);
178   ?>
179   
180   <tr>
181     <td align=
"center" bgcolor="<? echo $color; ?>" class="smallfont">
182     <input type=
"checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
183     <td align=
"center" bgcolor="<? echo $color; ?>" class="smallfont">
184     <a href=
"./?act=news_m&cat=<? echo $_REQUEST['cat']; ?>&id=<? echo $row['id']; ?>&page=<? echo $_REQUEST['page'];?>">S&#7917;a</a></td>
185     <td align=
"center" bgcolor="<? echo $color; ?>" class="smallfont">
186     <a onclick=
"return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" href="./?act=news&action=del&cat=<? echo $_REQUEST['cat']; ?>&id=<? echo $row['id']; ?>">Xóa</a></td>
187     <td bgcolor=
"<? echo $color; ?>" align="left" align="left" class="smallfont"><? echo $row['id']; ?>&nbsp;</td>
188     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?>&nbsp;</td>
189     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?>&nbsp;</td>
190     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? if($row['top']=='1'){?><font color="blue">Yes</font><?}else{?><font color="red">No</font><?}?></td>
191     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['image']; ?>&nbsp;</td>
192     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['date']; ?>&nbsp;</td>
193     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row_cat['name']; ?>&nbsp;</td>
194   </tr>
195   <?
196                 }
197   ?>
198 </table>
199 <table border=
"0" width="100%" cellspacing="0" cellpadding="0" id="table1">
200     <tr>
201         <td>
202        <input type=
"submit" value="Xóa Ch&#7885;n" name="ButDel" onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" class="button"></td>
203        <td align=
"right">
204         <input type=
"submit" value="Ch&#7885;n là tin top" name="newstop" class="button">
205         <input type=
"submit" value="Hủy tin top" name="un_newstop" class="button">
206         </td>
207     </tr>
208 </table>
209 </form>
210 <script language=
"JavaScript">
211 function chkallClick(o) {
212     
var form = document.frmList;
213     
for (var i = 0; i < form.elements.length; i++) {
214         
if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
215             form.elements[i].
checked = document.frmList.chkall.checked;
216         }
217     }
218 }
219 </script>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.823 lượt xem

Gõ tìm kiếm nhanh...